<template>
	<el-form
		ref="form"
		class="plr-1"
		label-position="top"
		:model="form"
		:rules="rules"
		:disabled="saving"
	>
		<div class="tips">字段：{{ fields }}</div>
		<el-form-item label="城市" prop="city_data">
			<el-select
				v-model="form.city_data"
				multiple
				collapse-tags
				filterable
				clearable
				style="width: 100%"
			>
				<el-option v-for="v in cityList" :key="v.value" :value="v.label" :label="v.label" />
				<el-option value="其他" label="其他" />
			</el-select>
		</el-form-item>
		<el-form-item prop="is_payment" label="开启表单支付">
			<cl-select v-model="form.is_payment" style="width: 100%">
				<el-option :value="1" label="是" />
				<el-option :value="0" label="否" />
			</cl-select>
		</el-form-item>
		<el-form-item prop="pay_result_land" label="落地页页面参数">
			<div class="tips" style="line-height: normal;">
				支付完成跳转落地页，默认不填则默认跳转支付结果
			</div>
			<el-input v-model="form.pay_result_land" placeholder="请输入落地页页面参数" />
		</el-form-item>
		<el-form-item label="支付方式" prop="form_pay">
			<cl-select v-model="form.form_pay" style="width: 100%">
				<el-option :value="1" label="先表单后支付" />
				<el-option :value="2" label="先支付后表单" />
			</cl-select>
		</el-form-item>
		<el-form-item prop="original_cost" label="支付原价">
			<el-input
				v-model="form.original_cost"
				placeholder="请输入金额"
				oninput="value=value.replace(/[^\d^\.]/g,'')"
				@blur="form.original_cost = $event.target.value"
			/>
		</el-form-item>
		<el-form-item prop="pay_money" label="支付金额">
			<el-input
				v-model="form.pay_money"
				placeholder="请输入支付金额"
				oninput="value=value.replace(/[^\d^\.]/g,'')"
				@blur="form.pay_money = $event.target.value"
			/>
		</el-form-item>
		<el-form-item prop="discount_money" label="优惠金额">
			<el-input
				v-model="form.discount_money"
				placeholder="请输入优惠金额"
				oninput="value=value.replace(/[^\d^\.]/g,'')"
				@blur="form.discount_money = $event.target.value"
			/>
		</el-form-item>
	</el-form>
</template>
<script>
import { cityList } from "@/assets/countryLevel3";

export default {
	props: {
		saving: Boolean,
		view: {
			type: Object,
			default: () => ({})
		}
	},
	data() {
		return {
			cityList,
			form: this.view.options,
			rules: {
				city_data: [{ required: false, message: "请填写城市" }],
				original_cost: [{ required: true, message: "请填写支付原价" }],
				pay_money: [{ required: true, message: "请填写支付金额" }]
			}
		};
	},
	computed: {
		fields() {
			return this.form.fields.map(v => v.label).join("、");
		}
	}
};
</script>
